#region Using Statements

using System.Windows.Controls;
using Merlba.MVVM.Module.Football.Models;
using Merlba.MVVM.Module.Football.Services;
using Merlba.MVVM.Module.Football.Views;

#endregion

namespace Merlba.MVVM.Module.Football.ViewModels
{
    public class ScoreboardViewModel : IScoreboardViewModel
    {
        private readonly IFootballService _footballService;
        private readonly ScoreBoardView _view;
        private MatchResult _matchResult;

        public ScoreboardViewModel(IFootballService footballService, ScoreBoardView view)
        {
            _view = view;
            _footballService = footballService;
        }

        public string HomeTeamName
        {
            get { return _matchResult.HomeTeam.TeamName; }
        }

        public string AwayTeamName
        {
            get { return _matchResult.AwayTeam.TeamName; }
        }

        public int HomeGoals
        {
            get { return _matchResult.HomeTeamScore.Goals; }
        }

        public int HomeBehinds
        {
            get { return _matchResult.HomeTeamScore.Behind; }
        }

        public int HomeScore
        {
            get { return _matchResult.HomeTeamScore.ScoreTotal; }
        }

        public int AwayGoals
        {
            get { return _matchResult.AwayTeamScore.Goals; }
        }

        public int AwayBehinds
        {
            get { return _matchResult.AwayTeamScore.Behind; }
        }

        public int AwayScore
        {
            get { return _matchResult.AwayTeamScore.ScoreTotal; }
        }
        #region IScoreboardViewModel Members

        public UserControl View
        {
            get { return _view; }
        }

        public void Initialise()
        {
            _matchResult = _footballService.GetMatchResult();
            _view.DataContext = this;
        }

        #endregion

        public void GetLatestMatchResult()
        {
            _matchResult = _footballService.GetMatchResult();
        }
    }
}